/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.infrastructure.message.serialization;

import cn.hallele.infrastructure.message.util.CodecUtil;
import org.apache.kafka.common.serialization.Deserializer;

/**
 * 发序列化器，byte类
 *
 * @author anle5
 * @since 2024/9/11 23:28
 */
public class ByteDeSerializer implements Deserializer<Object> {
    /**
     * 默认构造
     */
    public ByteDeSerializer() {
        super();
    }

    /**
     * Deserialize a record value from a byte array into a value or object.
     *
     * @param topic topic associated with the data
     * @param data  serialized bytes; may be null; implementations are recommended to handle null by returning a value or null rather than throwing an exception.
     * @return deserialized typed data; may be null
     */
    @Override
    public Object deserialize(String topic, byte[] data) {
        return CodecUtil.byte2Obj(data);
    }
}
